﻿using Basic.HrRemoteModel.Emp;
using Basic.HrRemoteModel.Emp.Model;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Helper;

namespace Basic.FlowExtendService.lmpl
{
    [ClassLifetimeAttr(ClassLifetimeType.SingleInstance)]
    internal class EmpService : IEmpService
    {
        public Dictionary<long, string> GetNames ( long[] empId )
        {
            if ( empId.IsNull() )
            {
                return null;
            }
            return new GetEmpNames
            {
                Ids = empId
            }.Send();
        }
        public EmpUnitDept[] GetsUnitDept ( long[] empId )
        {
            if ( empId.IsNull() )
            {
                return Array.Empty<EmpUnitDept>();
            }
            return new GetEmpUnitDepts
            {
                EmpId = empId
            }.Send();
        }
        public EmpBase GetBase ( long id )
        {
            return new GetEmpBase
            {
                Id = id
            }.Send();
        }
        public EmpBase[] GetBase ( long[] ids )
        {
            if ( ids.IsNull() )
            {
                return null;
            }
            return new GetEmpBases
            {
                Ids = ids
            }.Send();
        }
        public WhileEmpResult GetWhileAuditEmp ( WhileFilterParam param )
        {
            return new GetWhileAuditEmp
            {
                FilterParam = param
            }.Send();
        }
        public SearchEmpResult SearchAuditEmp ( EmpSearchParam param, int take, int page )
        {
            return new SearchAuditEmp
            {
                Param = param,
                Take = take,
                Index = page
            }.Send();
        }
        public Dictionary<long, EmpInfo> GetInfos ( long[] empId )
        {
            EmpInfo[] emps = this.GetInfo(empId);
            if ( emps.IsNull() )
            {
                return new Dictionary<long, EmpInfo>();
            }
            return emps.ToDictionary(a => a.EmpId, a => a);
        }
        public EmpInfo[] GetInfo ( long[] empId )
        {
            return new GetEmpInfos
            {
                EmpId = empId
            }.Send();
        }
        public string[] GetName ( long[] empId )
        {
            if ( empId.IsNull() )
            {
                return null;
            }
            return new GetEmpNameList
            {
                Ids = empId
            }.Send();
        }
        public string GetName ( long empId )
        {
            return new GetEmpName
            {
                Id = empId
            }.Send();
        }
        public EmpInfo GetInfo ( long empId )
        {
            return new GetEmpInfo
            {
                EmpId = empId
            }.Send();
        }
    }
}
